// 设备信息相关参数的获取
import {NativeModules, Platform, StatusBar} from 'react-native';

export default class DeviceInfo {
  static getDeviceStatusBarHeight() {
    if (Platform.OS === 'ios') {
      const {StatusBarManager} = NativeModules;
      // 获取 ios 状态栏的高度
      return new Promise((resolve) => {
        StatusBarManager.getHeight((statusBarHeight) => {
          resolve(statusBarHeight.height);
        });
      });
    } else {
      // 获取 android 状态栏的高度
      const statusBarHeight = StatusBar.currentHeight;
      return parseInt(statusBarHeight, 10);
    }
  }
}
